package main

import (
	"fmt"
	"reflect"
	"strconv"
)

type Cal struct {
	Num1 int
	Num2 int
}

func (c Cal) GetSub(name string) {
	res := strconv.Itoa(c.Num1 - c.Num2)
	num1 := strconv.Itoa(c.Num1)
	num2 := strconv.Itoa(c.Num2)
	fmt.Println(name + " 完成了减法运行，" +
		num1 + " - " + num2 + " = " + res)
}

func TestStruct(a interface{}) {

	val := reflect.ValueOf(a)
	num := val.NumField()
	for i := 0; i < num; i++ {
		fmt.Printf("Field %d: 值为=%v\n", i, val.Field(i))
	}

	var params []reflect.Value
	params = append(params, reflect.ValueOf("tom"))
	val.Method(0).Call(params)

}

func main() {

	c := Cal{8, 3}
	TestStruct(c)

}